//*****************************************************************************
// JFab (http://code.google.com/p/jfab)
// Copyright (c) 2011-2012 JFab.org
// Admin jfab@jeffreythompson.net
//
// See the file "LICENSE.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//*****************************************************************************

package org.jfab.core.model;

/**
 * Provides an enumeration of modifiers.
 */
public enum Modifier
{
    /** Public. */
    PUBLIC("public", java.lang.reflect.Modifier.PUBLIC),
    /** Protected. */
    PROTECTED("protected", java.lang.reflect.Modifier.PROTECTED),
    /** Private. */
    PRIVATE("private", java.lang.reflect.Modifier.PRIVATE),

    /** Abstract. */
    ABSTRACT("abstract", java.lang.reflect.Modifier.ABSTRACT),
    /** Final. */
    FINAL("final", java.lang.reflect.Modifier.FINAL),
    /** Interface. */
    INTERFACE("interface", java.lang.reflect.Modifier.INTERFACE),
    /** Native. */
    NATIVE("native", java.lang.reflect.Modifier.NATIVE),
    /** Static. */
    STATIC("static", java.lang.reflect.Modifier.STATIC),
    /** Strict. */
    STRICT("strict", java.lang.reflect.Modifier.STRICT),
    /** Synchronized. */
    SYNCHRONIZED("synchronized", java.lang.reflect.Modifier.SYNCHRONIZED),
    /** Transient. */
    TRANSIENT("transient", java.lang.reflect.Modifier.TRANSIENT),
    /** Volatile. */
    VOLATILE("volatile", java.lang.reflect.Modifier.VOLATILE),

    /** Annotation. */
    ANNOTATION("annotation", 0x00002000),
    /** Enum. */
    ENUM("enum", 0x00004000),
    /** Synthetic. */
    SYNTHETIC("synthetic", 0x00001000);

    /**
     * @param name Name.
     * 
     * @return the modifier which corresponds to the given parameter.
     */
    public static Modifier valueOfName(final String name)
    {
        Modifier answer = null;

        final int size = values().length;

        for (int i = 0; (answer == null) && (i < size); i++)
        {
            final Modifier modifier = values()[i];

            if (modifier.getName().equals(name))
            {
                answer = modifier;
            }
        }

        return answer;
    }

    /** Name. */
    private final String _name;

    /** Modifiers. */
    private final Integer _value;

    /**
     * Construct this object with the given parameter.
     * 
     * @param name Name.
     * @param value Value.
     */
    private Modifier(final String name, final Integer value)
    {
        _name = name;
        _value = value;
    }

    /**
     * @return the name
     */
    public String getName()
    {
        return _name;
    }

    /**
     * @return the value
     */
    public Integer getValue()
    {
        return _value;
    }
}
